<template>
    <div>
        <el-table :data="$store.state.HomeModule.listdata.slice((currentPage-1)*pageSize,currentPage*pageSize)" style="width: 100%">
            <el-table-column prop="id" label="编号"  />
            <el-table-column prop="title" label="楼盘名称"  />
            <el-table-column prop="type" label="房源类型" />
            <el-table-column prop="num" label="门牌号" />
            <el-table-column prop="hometype" label="房源户型" />
            <el-table-column prop="name" label="户主" />
            <el-table-column label="编辑">
                <template #default="scope">
                  <el-button size="small" @click="handleEdit(scope.$index, scope.row)"
                    >修改</el-button
                  >
                  <el-button
                    size="small"
                    type="danger"
                    @click="handleDelete(scope.$index, scope.row)"
                    >删除</el-button
                  >
                </template>
              </el-table-column>
        </el-table>
        <el-pagination
       
          :page-size="pageSize"
          :current-page="currentPage"
          layout="total, sizes, prev, pager, next, jumper"
          :total="$store.state.HomeModule.listdata.length"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
        <ud/>
    </div>
</template>

<script lang="ts" setup>
import { ref,onMounted,reactive } from 'vue'
import link from "../../../api/request"
import apiUrl from "../../../api/url"
import Ud from "../../../components/UpdateDialog.vue"
import {useStore} from "vuex"
let store = useStore()
const currentPage = ref(1)
const pageSize = ref(15)
let search=ref("")
let tableData = reactive({
    listdata:[]
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleSizeChange = (val:any) => {
  pageSize.value = val
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleCurrentChange = (val:any) => {
    currentPage.value = val
}
const handleEdit = (index: number, row: any) => {
  store.commit("SET_DIALOG",row)
}
const handleDelete = (index: number, row: any) => {
  console.log(index, row)
  store.dispatch("DEL_DATA",row)
}

onMounted(()=>{
    store.dispatch("USERUPDATE_LIST")
    // link(apiUrl.userlist).then((res:any)=>{
    //     console.log(res,222)
    //     tableData.listdata = res.data
    // })
})
</script>

<style>

</style>